package com.stropheware.droidDefense;

import android.content.Context;

public class UtilityTower extends AbstractTower {
	
	private final static String TAG = "UtilityTower";
	protected Context context;
	public int upgradeLevel;
	
	public UtilityTower(Context context, GameBoard gameBoard, int topPx, int leftPx) {
		super(gameBoard, topPx, leftPx);
		this.context = context;
		init();
	}
	
	public UtilityTower(){
		super();
	}
	
	public UtilityTower(Context context, GameBoard gameBoard, Cell topLeftCell) {
		super(gameBoard, topLeftCell);
		this.context = context;
		init();
	}
	
	protected void init() {
		upgradeLevel = 0;
		drawable = context.getResources().getDrawable(R.drawable.utility_tower);
		damagePerShot = 25;
		currentTarget = null;
		radius = 6 * gameBoard.cellSideLength;
		speed = 10;
		cost = 100;
		isDamageMaker = true;
		numProjectiles = 10;
		projectiles = new BasicProjectile[numProjectiles];
		for (int i = 0; i < numProjectiles; i++)
			projectiles[i] = new BasicProjectile(gameBoard, this, context);
		
	}
	protected void upgradeToAdvanced(){
		upgradeLevel++;
		if(upgradeLevel > 4)return;
		if(upgradeLevel == 3){
			drawable = context.getResources().getDrawable(R.drawable.sell);
			damagePerShot *= 2;
			radius *= 2;
			speed *= 2;
		}
		else if(upgradeLevel == 2){
			drawable = context.getResources().getDrawable(R.drawable.upgrade);
			damagePerShot *= 2;
			radius *= 2;
			speed *= 2;
			}
		else if(upgradeLevel == 1){
			drawable = context.getResources().getDrawable(R.drawable.sell);
			damagePerShot *= 2;
			radius *= 2;
			speed *= 2;
			}
		
	}

}
